#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <stack>

using namespace std;

struct Node
{
    int a, b;
    Node( ) { }
    Node( int _a, int _b )
        : a( _a ), b( _b ) { }
};

bool operator < ( Node a, Node b ) { return a.a < b.a; }

int min( int a, int b ) { return ( a < b ) ?a :b; }

struct Point
{
    int x, y;
};

int f[ 1 << 20 ], pi[ 1 << 20 ][ 2 ], n;
Point c, p[ 20 ];

int dis( Point a, Point b )
{
    return ( a.x - b.x ) * ( a.x - b.x ) + ( a.y - b.y ) * ( a.y - b.y );
}

void init( )
{
    int i;
    scanf("%d%d", &c.x, &c.y);
    scanf("%d", &n);
    for ( i = 0; i < n; i++ )
        scanf("%d%d", &p[ i ].x, &p[ i ].y);
    f[ 0 ] = 0;
    memset( pi, -1, sizeof( pi ) );
}

void work( )
{
    int i, j, k, p1, p2;
    for ( i = 1; i < ( 1 << n ); i++ )
    {
        f[ i ] = 0x7fffffff;
        for ( j = 0; j < n; j++ )
        {
            if ( !( i & ( 1 << j ) ) ) continue;
            p1 = i ^ ( 1 << j );
            if ( f[ i ] > f[ p1 ] + 2 * dis( c, p[ j ] ) )
            {
                f[ i ] = f[ p1 ] + 2 * dis( c, p[ j ] );
                pi[ i ][ 0 ] = j;
            }
        }
        for ( j = 0; j < n; j++ )
        {
            if ( !( i & ( 1 << j ) ) ) continue;
            p1 = i ^ ( 1 << j );
            for ( k = 0; k < n; k++ )
            {
                if ( !( p1 & ( 1 << k ) ) ) continue;
                p2 = p1 ^ ( 1 << k );
                if ( f[ i ] > f[ p2 ] + dis( c, p[ k ] ) + dis( p[ k ], p[ j ] ) + dis( c, p[ j ] ) )
                {
                    f[ i ] = f[ p2 ] + dis( c, p[ k ] ) + dis( p[ k ], p[ j ] ) + dis( c, p[ j ] );
                    pi[ i ][ 0 ] = j;
                    pi[ i ][ 1 ] = k;
                }
            }
        }
    }
    i = ( 1 << n ) - 1;
    vector<Node> aa;
    while ( i )
    {
        if ( pi[ i ][ 1 ] != -1 )
        {
            aa.push_back( Node( pi[ i ][ 0 ], pi[ i ][ 1 ] ) );
            i ^= ( 1 << pi[ i ][ 0 ] ) ^ ( 1 << pi[ i ][ 1 ] );
        }
        else
        {
            aa.push_back( Node( pi[ i ][ 0 ], -1 ) );
            i ^= 1 << pi[ i ][ 0 ];
        }
    }
    printf("%d\n", f[ ( 1 << n ) - 1 ]);
    sort( aa.begin( ), aa.end( ) );
    for ( i = 0; i < aa.size( ); i++ )
    {
        if ( i != 0 ) printf(" ");
        printf("%d", aa[ i ].a + 1);
        if ( aa[ i ].b != -1 )
            printf(" %d", aa[ i ].b + 1);
    }
    puts("");
}

int main( )
{
    int t, cas = 1;
    scanf("%d", &t);
    while ( t-- )
    {
        init( );
        printf("Case %d:\n", cas++);
        work( );
    }
    return 0;
}
